package com.ross.mode;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0.0
 * @className: ShapeCache
 * @description:
 * @author: zhangjunfa
 * @date: 2023/4/3 14:24
 */
public class ShapeCache {
    private static Map<String, Shape> shapeMap = new HashMap<String, Shape>();

    public static Shape getShape(String shapeId) {
        Shape shape = shapeMap.get(shapeId);
        return (Shape) shape.clone();
    }


    public static void loadCache() {
        Rectangle rectangle = new Rectangle();
        rectangle.setId("1");
        shapeMap.put(rectangle.getId(), rectangle);

        Square square = new Square();
        square.setId("2");
        shapeMap.put(square.getId(), square);

    }


}
